﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'userUpdate')
	BEGIN
		DROP  Procedure  userUpdate
	END
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[userUpdate] 
	-- Add the parameters for the stored procedure here
	@user_name VARCHAR(50), 
	@user_pwd VARCHAR(50),
	@first_name VARCHAR(50), 
	@last_name VARCHAR(50),
	@user_id INT
AS
BEGIN
	SET NOCOUNT ON;

	-- Insert statements for procedure here
	IF (EXISTS(	SELECT * 
					FROM lit_usuario
					WHERE lit_usuario_id = @user_id)) 
	BEGIN
		UPDATE lit_usuario
		SET lit_usuario_username = @user_name,
			lit_usuario_password = @user_pwd,
			lit_usuario_nombre = @first_name,
			lit_usuario_apellido = @last_name
		WHERE lit_usuario_id = @user_id;
		SELECT 1;
	END
	ELSE SELECT 0;
END
GO